import logging
from flask import Blueprint, json, Response, request

logger = logging.getLogger("default")
permission_bp = Blueprint('permission', __name__, url_prefix='/permission')


def reg_permission_bp(app):
    app.register_blueprint(permission_bp)


@permission_bp.route('/list')
def get_permission():
    data = {
        "code": 200,
        "data": {
            "menu": [
                {

                        "name": "SQL",
                        "path": "/sql",
                        "meta": {
                            "title": "SQL",
                            "icon": "el-icon-eleme-filled",
                            "type": "menu"
                        },
                        "children": [
                            {
                                "name": "sqlquery_new",
                                "path": "/sql/sqlquery_new",
                                "meta": {
                                    "title": "sql查询",
                                    "icon": "el-icon-menu"
                                },
                                "component": "sqlquery_new"
                            },
                        ]

                },
                {
                    "name": "other",
                    "path": "/other",
                    "meta": {
                        "title": "其他",
                        "icon": "el-icon-more-filled",
                        "type": "menu"
                    },
                    "children": [
                        {
                            "path": "/link",
                            "name": "link",
                            "meta": {
                                "title": "外部链接",
                                "icon": "el-icon-link",
                                "type": "menu"
                            },
                            "children": [
                                {
                                    "path": "https://baidu.com",
                                    "name": "百度",
                                    "meta": {
                                        "title": "百度",
                                        "type": "link"
                                    }
                                },
                                {
                                    "path": "https://www.google.cn",
                                    "name": "谷歌",
                                    "meta": {
                                        "title": "谷歌",
                                        "type": "link"
                                    }
                                }
                            ]
                        },
                    ]
                }
            ],
            "permissions": [
                "list.add",
                "list.edit",
                "list.delete"
            ]
        },
        "message": ""
    }
    return Response(json.dumps(data))
